<template>
	<view class="page_1">
		<view class="box">
			<view class="top"  v-if="myinfo.img">
				<image :src="myinfo.img.split(',')[0]"></image>
				<view class="small_title">{{myinfo.course_name}} </view>
				<view style="margin-top: 10rpx;font-size: 26rpx;">学员名称：{{studentinfo.username}} </view>
				<view class="starbox">
					<view class="text">学习成果：</view>
					<uni-rate :value="major" color="#bbb" active-color="#FF8A9B"  :size="24" max="5" @change="e=>onChange(e,1)"/>
				</view>
				<view class="starbox">
					<view class="text">作业方面：</view>
					<uni-rate :value="manner" color="#bbb" active-color="#FF8A9B" :size="24" max="5" @change="e=>onChange(e,2)"/>
				</view>
				<!-- <view class="score">
					<view class="text">总体打分</view>
					<uni-rate :value="3" :size="16" max="5" @change="onChange"/>
				</view> -->
				<view class="line"></view>
			</view>
			<view class="textareabox">
				<textarea maxlength="99999" v-model="content" placeholder="可以从多个角度评价宝贝，可以帮助更多想买的人哦~~"></textarea>
			</view>
			<view class="addimg" v-if="imglist.length==0" @click="uploadimg()">
				<image src="../../static/xj.png"></image>
				<view>添加图片</view>
			</view>
			<view class="imgbox" v-else>
				<view class="imglist" v-for="(item,index) in imglist" :key="index">
					<image :src="item" style="border-radius: 16rpx;"></image>
					<image class="closen" src="../../static/off.png" @click="spliceimg(index)"></image>
				</view>
				<view class="imglist" @click="uploadimg()" style="border:2rpx dashed #999999,width:33%" v-if="imglist.length<6">
					<image style="width: 66rpx;height: 60rpx; margin: 50rpx 0 10rpx 0;" src="../../static/xj.png">
					</image>
					<view>添加图片</view>
				</view>
			</view>
		</view>
		<!-- <view class="box" v-if="info.avator">
			<view class="top" style="padding-bottom: 30rpx;">
				<image :src="info.avator.split(',')[0]"></image>
				<view class="small_title">{{info.teacher_name}} </view>
				<view class="starbox">
					<view class="text">学生学习成果：</view>
					<uni-rate :value="major" color="#bbb" active-color="#FF8A9B"  :size="24" max="5" @change="e=>onChange(e,1)"/>
				</view>
				<view class="starbox">
					<view class="text">学生作业方面：</view>
					<uni-rate :value="manner" color="#bbb" active-color="#FF8A9B" :size="24" max="5" @change="e=>onChange(e,2)"/>
				</view>
			</view>
		</view> -->
		<!-- 匿名 -->
		<!-- <view class="anonymous">length
			<image src="../../static/gou.png" v-if="isRadio" @click="radioNoActive"></image>
			<image src="../../static/yuan.png" v-else @click="radioNoActive"></image>
			<view class="text" @click="radioNoActive">匿名发布评论</view>
		</view> -->
		<!-- 底部按钮 -->
		<view style="height: 120rpx;"></view>
		<view class="btn" @click="sumbit()">
			<view>提交</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info:{},
				imglist:[],
				major:'',
				manner:'',
				content:'',
				id:'',
				myinfo:{},//课程详情
				studentinfo:{},//学生详情
			};
		},
		onLoad(option) {
			this.studentinfo =JSON.parse(decodeURIComponent(option.studentinfo))
			this.myinfo = JSON.parse(decodeURIComponent(option.myinfo))
		},
		methods:{
			sumbit(){
				if(!this.content||!this.major||!this.manner){
					uni.showToast({
						title:'请填写完整信息',
						icon:'none'
					})
					return
				}
				this.$http({
					url:'/api/course/course_eval',
					data:{
						order_id:this.studentinfo.id,
						teacher_course_id:this.studentinfo.teacher_course_id,
						major:this.major,
						manner:this.manner,
						content:this.content,
						img:this.imglist.join('|'),
						type:2,//1学生2老师评价
						user_id:this.studentinfo.uid,
						teacher_id:this.studentinfo.teacher_id,
						order_family_id:this.studentinfo.id
					}
				}).then(res=>{
					uni.showToast({
						title:res.msg,
						icon:'none'
					})
					uni.navigateBack({
						delta:1
					})
				})
			},
			// getinfo(id){
			// 	this.$http({
			// 		url:'/api/course/order_detail',
			// 		data:{
			// 			id:id,
			// 			teacher_course_id:this.id
			// 		}
			// 	}).then(res=>{
			// 		this.info = res.data
			// 	})
			// },
			onChange(e,n) {
				if(n==1){
					this.major = e.value
				}else{
					this.manner = e.value
				}
				console.log(e,n);
			},
			//添加图片
			uploadimg() {
				this.$upload(1).then(res => {
					this.imglist.push(...res)
					console.log(this.imglist, 'this.imglist', res) //item.file.full_url
				})
			},
			//删除图片
			spliceimg(index) {
				this.imglist.splice(index, 1)
			},
		}
	}
</script>
<style>
	.textareaClass {
		font-size: 28rpx;
		font-family: Source Han Sans CN-Regular, Source Han Sans CN;
		font-weight: 400;
		color: #888888;
	}
</style>
<style lang="scss" scoped>
	.page_1{
		padding-bottom: 160rpx;
	}
	.box {
		width: 750rpx;
		// min-height: 704rpx;
		background: #FFFFFF;
		border-radius: 0rpx 0rpx 10rpx 10rpx;
		margin-top: 76rpx;
		padding: 0 30rpx 24rpx 30rpx;
		box-sizing: border-box;
		position: relative;
		display: flex;
		flex-direction: column;
	
		.top {
			flex-shrink: 0;
			height: 334rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			align-items: center;
	
			image {
				position: absolute;
				left: 50%;
				top: 0;
				transform: translate(-50%, -50%);
				width: 120rpx;
				height: 120rpx;
				border-radius: 7rpx 7rpx 7rpx 7rpx;
			}
	
			.small_title {
				margin-top: 82rpx;
				text-align: center;
				font-size: 26rpx;
				font-family: Source Han Sans CN-Regular, Source Han Sans CN;
				font-weight: 400;
				color: #888888;
				line-height: 1em;
			}
			.starbox{
				display: flex;
				justify-content: center;
				font-size: 32rpx;
				font-family: Source Han Sans CN-Regular, Source Han Sans CN;
				font-weight: 400;
				color: #222222;
				align-items: center;
				height: 60rpx;
				margin-top: 20rpx;
				.text{
				    display: inline-block;
				    width: 200rpx;
				    height: 20px; /*高度需要添加，不然文字下面会多出一些空隙*/
				    text-align: justify;
				    &::after {
				      content: "";
				      display: inline-block;
				      width: 100%;
				    }
				 }
			}
	
			.score {
				display: flex;
				align-items: center;
				justify-content: center;
				gap: 0 20rpx;
				position: relative;
				.score_text{
					font-size: 24rpx;
					font-family: Source Han Sans CN-Regular, Source Han Sans CN;
					font-weight: 400;
					color: #CB9852;
					position: absolute;
					right: -94rpx;
				}
				.text {
					font-size: 28rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #222222;
				}
			}
	
			.line {
				width: 100%;
				background: #FFFFFF;
				border: 2rpx solid #F1F1F1;
			}
		}
	
		.textareabox {
			width: 100%;
			// height: 372rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			padding: 20rpx 0;
		
			>textarea {
				width: 90%;
				margin: 0rpx auto;
			}
		}
		
		.addimg {
			height: 236rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			text-align: center;
			font-size: 28rpx;
			font-family: SourceHanSansCN-Medium-, SourceHanSansCN-Medium;
			font-weight: normal;
			color: #999999;
			margin-top: 20rpx;
			border: 2rpx dashed #999999;
		
			image {
				width: 66rpx;
				height: 60rpx;
				margin-top: 50rpx;
				margin-bottom: 10rpx;
			}
		}
		
		.imgbox {
			display: flex;
			flex-wrap: wrap;
			margin-top: 20rpx;
		
			.imglist {
				width: 33.3%;
				text-align: center;
				position: relative;
		
				image {
					width: 208rpx;
					height: 208rpx;
				}
		
				.closen {
					width: 40rpx;
					height: 40rpx;
					position: absolute;
					right: 10rpx;
					top: 0;
				}
			}
		}
	}
	
	// 匿名，
	.anonymous {
		margin-top: 24rpx;
		width: 750rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		padding: 38rpx;
		display: flex;
		align-items: center;
		gap: 0 14rpx;
	
		image {
			width: 32rpx;
			height: 32rpx;
		}
	
		.text {
			font-size: 28rpx;
			font-family: Source Han Sans CN-Regular, Source Han Sans CN;
			font-weight: 400;
			color: #222222;
		}
	}
	
	// 底部按钮
	.btn{
		width: 100%;
		height: 120rpx;
		bottom: 0;
		position: fixed;
		background-color: #FFF;
		>view{
			width: 690rpx;
			margin: 10rpx auto;
			height: 84rpx;
			border-radius: 83rpx ;
			font-size: 32rpx;
			font-family: Source Han Sans CN-Medium, Source Han Sans CN;
			font-weight: 500;
			color: #FFFFFF;
			text-align: center;
			background:#FF8A9B;
			line-height: 84rpx;
		}
	}
</style>
